package glory.xxd;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

/**
 * 监听
 */
class MyListener implements MessageListener {
    //继承MessageListener接口并重新它的onMessage方法
    @Override
    public void onMessage(Message message) {
        System.out.println("进入监听");
        try {
            TextMessage textMessage = (TextMessage) message;
            //取消息内容
            String text = textMessage.getText();
            System.out.println(text);
        } catch (JMSException e) {
            e.printStackTrace();
        }
    }
}